package com.yc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.bean.QuestionDimension;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface QuestionDimensionDao extends BaseMapper<QuestionDimension> {
    
    /**
     * 根据题目ID查询所有关联的维度
     */
    @Select("SELECT * FROM questionDimensions WHERE questionId = #{questionId}")
    List<QuestionDimension> selectByQuestionId(@Param("questionId") Long questionId);
    
    /**
     * 根据维度ID查询所有关联的题目
     */
    @Select("SELECT * FROM questionDimensions WHERE dimensionId = #{dimensionId}")
    List<QuestionDimension> selectByDimensionId(@Param("dimensionId") Long dimensionId);
    
    /**
     * 根据测评ID查询所有题目维度关联
     */
    @Select("SELECT qd.* FROM questionDimensions qd " +
            "INNER JOIN testQuestions tq ON qd.questionId = tq.questionId " +
            "WHERE tq.testId = #{testId}")
    List<QuestionDimension> selectByTestId(@Param("testId") Long testId);
} 